/*
 * ShipStatus.cpp
 *
 *  Created on: Nov 8, 2011
 *      Author: gonzalo
 */

#include "ShipStatus.h"

ShipStatus::ShipStatus(DTOShipStatus* shipStatus){
	this->owner = shipStatus->getOwner();
	this->imagen = shipStatus->imagen;
	this->velRotacion = shipStatus->velRotacion;
	this->velMaxima = shipStatus->velMaxima;
	this->propulsion = shipStatus->propulsion;
	this->friccion = shipStatus->friccion;
	this->duracionBala = shipStatus->duracionBala;
	this->propulsion = shipStatus->propulsion;
	this->angle = shipStatus->angle;
	this->posX = shipStatus->posX;
	this->posY = shipStatus->posY;
	this->drawable = shipStatus->drawable;

	std::list<DTOEquipment*>::iterator it;
	for (it = shipStatus->userEquipment.begin(); it != shipStatus->userEquipment.end(); ++it) {
		this->userEquipment.push_back((DTOEquipment*)InstanceDuplicater::duplicate(*it));
	}
}


ShipStatus::ShipStatus(std::string owner, std::string imagen, float velRotacion,	int velMaxima,
					int propulsion, int friccion, int duracionBala,int angle,
					int posX, int posY,std::list<DTOEquipment*> userEquipment, bool drawable) {
	this->owner = owner;
	this->imagen = imagen;
	this->velRotacion = velRotacion;
	this->velMaxima = velMaxima;
	this->propulsion = propulsion;
	this->friccion = friccion;
	this->duracionBala = duracionBala;
	this->angle = angle;
	this->posX = posX;
	this->posY = posY;
	this->drawable = drawable;
	this->userEquipment = userEquipment;
}


DTOShipStatus* ShipStatus::transformInDTO(){
	return new DTOShipStatus(owner,imagen,velRotacion,velMaxima,propulsion,friccion,duracionBala,angle,posX,posY,userEquipment,drawable);
}

void ShipStatus::setOwner(std::string realOwner){
	owner = realOwner;
}

std::string ShipStatus::getOwner(){
	return owner;
}
int ShipStatus::getPosX(){
	return posX;
}
int ShipStatus::getPosY(){
	return posY;
}

ShipStatus::~ShipStatus() {
	while(!userEquipment.empty()){
		delete userEquipment.front();
		userEquipment.pop_front();
	}

}

int ShipStatus::getDuracionBala() const
{
    return duracionBala;
}

int ShipStatus::getFriccion() const
{
    return friccion;
}

std::string ShipStatus::getImagePath() const
{
    return imagen;
}

int ShipStatus::getPropultion() const
{
    return propulsion;
}

int ShipStatus::getVelMax() const
{
    return velMaxima;
}

float ShipStatus::getVelRotacion() const
{
    return velRotacion;
}

int ShipStatus::getAngle() const {
	return angle;
}

void ShipStatus::setAngle(int angle) {
	this->angle = angle;
}

std::list<DTOEquipment*> ShipStatus::getEquipment(){
	return this->userEquipment;
}

bool ShipStatus::getDrawable(){
	return drawable;
}

void ShipStatus::updatePosition(int xPosition,int yPosition){
	this->posX = xPosition;
	this->posY = yPosition;
}

